import React from 'react'
import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom'
import Login from "../pages/login"
import NewsSandBox from "../pages/sendbox"
import Tourist from '../pages/tourist/tourist'
import TouristDetail from "../pages/tourist/touristDetail"
export default function IndexRouter() {
  return (
    <BrowserRouter>
      <Switch>
        <Route path="/login" component={Login} />
        <Route path="/tourist" component={Tourist} />
        <Route path="/touristDetail/:id" component={TouristDetail} />
        <Route path='/' render={() => {
          return localStorage.getItem("token") ? <NewsSandBox></NewsSandBox> : <Redirect to="/login" />
        }} />
        {/* <Route path="/" component={NewsSandBox}></Route> */}
      </Switch>
    </BrowserRouter>
  )
}
